Column

The boxplot of total product numbers within aisle

Column

Chart B

Chart C

# A tibble: 1,000 × 9
   order_id product_id user_id product_name      aisle_id aisle      department department_id
      <int>      <int>   <int> <chr>                <int> <chr>      <chr>              <int>
 1   764640      24307   62787 Chunky Blue Chee…       89 salad dre… pantry                13
 2  2190647      21137   59753 Organic Strawber…       24 fresh fru… produce                4
 3   190523      34283  122574 Fudgsicle No Sug…       37 ice cream… frozen                 1
 4  1504527      14233  199450 Natural Artesian…      115 water sel… beverages              7
 5  1762556      34358  162678 Garlic                  83 fresh veg… produce                4
 6  3170814      24852   82433 Banana                  24 fresh fru… produce                4
 7  2216610       4464  189448 Fruit Spread, De…       88 spreads    pantry                13
 8   222884      21137  129416 Organic Strawber…       24 fresh fru… produce                4
 9  1025981       4605  103552 Yellow Onions           83 fresh veg… produce                4
10  3105153       8073     111 Basmati Ready Ri…        4 instant f… dry goods…             9
# … with 990 more rows, and 1 more variable: order_number <int>
---
title: "DashBoard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)
library(plotly)
```

```{r data_cleaning}
data("instacart")
instacart = 
  instacart%>% 
  sample_n(1000) %>% # select 1000 observations
  select(order_id, product_id, user_id, product_name, aisle_id, aisle, department, department_id, order_number)
```

Column {data-width=850}
-----------------------------------------------------------------------

### The boxplot of total product numbers within aisle

```{r}
instacart %>%
  group_by(aisle, aisle_id, product_name) %>% 
  summarize(sum = sum(order_number)) %>% 
  mutate(aisle= fct_reorder(aisle, sum)) %>% 
  plot_ly(
    y = ~ sum,
    x = ~ aisle,
    type = "box",
    color = ~aisle,
    colors = "viridis"
  )

```

Column {data-width=350}
-----------------------------------------------------------------------

### Chart B

```{r}
instacart %>% 
  group_by(aisle, aisle_id, product_name) %>% 
  summarize(sum = sum(order_number)) %>% 
  mutate(text_label = str_c("Product :", product_name,"\nAisle:", aisle)) %>% 
  plot_ly(
    x = ~aisle_id, y = ~sum, color = ~sum, text = ~ text_label, 
    alpha = 0.5, type = "scatter", mode = "markers")
```

### Chart C

```{r}
instacart 
  
```